# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>

pkgname=miniserve
pkgver=0.23.2
pkgrel=2
pkgdesc="Tool to serve files via HTTP"
arch=('loong64' 'x86_64')
url="https://github.com/svenstaro/miniserve"
license=('MIT')
depends=('gcc-libs' 'bzip2')
makedepends=('rust')
options=(!lto)
source=(miniserve-$pkgver.tar.gz::https://github.com/svenstaro/miniserve/archive/v${pkgver}.tar.gz)
sha512sums=('6aac91253b17b7b1d8d0d1fd94b0b06fa037670e711d796396bab9efeb01e7a29efd19c95b8e05286bf520a6065bb9c33fb6fd9e54137d7ef7587634a1695fa7')

build() {
  cd "$srcdir/$pkgname-$pkgver"

  cargo build --release --locked
}

check() {
  cd "$srcdir/$pkgname-$pkgver"

  cargo test --release --locked -- --test-threads=1
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  install -Dm755 target/release/miniserve "$pkgdir"/usr/bin/miniserve

  mkdir -p "$pkgdir"/usr/share/{bash-completion/completions,zsh/site-functions,fish/vendor_completions.d}
  target/release/miniserve --print-completions bash > "$pkgdir"/usr/share/bash-completion/completions/miniserve
  target/release/miniserve --print-completions zsh > "$pkgdir"/usr/share/zsh/site-functions/_miniserve
  target/release/miniserve --print-completions fish > "$pkgdir"/usr/share/fish/vendor_completions.d/miniserve.fish

  mkdir -p "$pkgdir"/usr/share/man/man1
  target/release/miniserve --print-manpage | gzip > "$pkgdir"/usr/share/man/man1/$pkgname.1.gz

  install -Dm644 packaging/miniserve@.service "$pkgdir"/usr/lib/systemd/system/miniserve@.service

  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
